Crate rustpython_ast

Source
Expand description

Python AST node definitions and utilities.

AST nodes are very similary defined like Python AST. But a few exceptions exist due to parser optimization. They can be transformed to matching Python-styled AST in reasonable cost.

PythonArguments is replaced by Arguments. The new Arguments type representation uses a new type ArgWithDefault to represent arguments with default values. See each type documentation for more details.

A few top-level sum types are renamed to human friendly names. CmpOp refers cmpop UnaryOp refers unaryop BoolOp refers boolop WithItem refers withitem ExceptHandler refers excepthandler

Re-exports§

pub use fold::Fold;
pub use crate::Node;
pub use malachite_bigint as bigint;

Modules§

fold
located
source_code
text_size
Newtypes for working with text sizes/ranges in a more type-safe manner.

Structs§

Alias
See also alias
Arg
See also arg
ArgWithDefault
An alternative type of AST arg. This is used for each function argument that might have a default value. Used by Arguments original type.
Arguments
An alternative type of AST arguments. This is parser-friendly and human-friendly definition of function arguments. This form also has advantage to implement pre-order traverse. defaults and kw_defaults fields are removed and the default values are placed under each arg_with_default typed argument. vararg and kwarg are still typed as arg because they never can have a default value.
BoolOpAnd
BoolOpOr
CmpOpEq
CmpOpGt
CmpOpGtE
CmpOpIn
CmpOpIs
CmpOpIsNot
CmpOpLt
CmpOpLtE
CmpOpNotEq
CmpOpNotIn
Comprehension
See also comprehension
EmptyRange
ExceptHandlerExceptHandler
See also ExceptHandler
ExprAttribute
See also Attribute
ExprAwait
See also Await
ExprBinOp
See also BinOp
ExprBoolOp
See also BoolOp
ExprCall
See also Call
ExprCompare
See also Compare
ExprConstant
See also Constant
ExprContextDel
ExprContextLoad
ExprContextStore
ExprDict
See also Dict
ExprDictComp
See also DictComp
ExprFormattedValue
See also FormattedValue
ExprGeneratorExp
See also GeneratorExp
ExprIfExp
See also IfExp
ExprJoinedStr
See also JoinedStr
ExprLambda
See also Lambda
ExprList
See also List
ExprListComp
See also ListComp
ExprName
See also Name
ExprNamedExpr
See also NamedExpr
ExprSet
See also Set
ExprSetComp
See also SetComp
ExprSlice
See also Slice
ExprStarred
See also Starred
ExprSubscript
See also Subscript
ExprTuple
See also Tuple
ExprUnaryOp
See also UnaryOp
ExprYield
See also Yield
ExprYieldFrom
See also YieldFrom
Identifier
Int
Keyword
See also keyword
MatchCase
See also match_case
ModExpression
See also Expression
ModFunctionType
See also FunctionType
ModInteractive
See also Interactive
ModModule
See also Module
OperatorAdd
OperatorBitAnd
OperatorBitOr
OperatorBitXor
OperatorDiv
OperatorFloorDiv
OperatorLShift
OperatorMatMult
OperatorMod
OperatorMult
OperatorPow
OperatorRShift
OperatorSub
PatternMatchAs
See also MatchAs
PatternMatchClass
See also MatchClass
PatternMatchMapping
See also MatchMapping
PatternMatchOr
See also MatchOr
PatternMatchSequence
See also MatchSequence
PatternMatchSingleton
See also MatchSingleton
PatternMatchStar
See also MatchStar
PatternMatchValue
See also MatchValue
PythonArguments
See also arguments
StmtAnnAssign
See also AnnAssign
StmtAssert
See also Assert
StmtAssign
See also Assign
StmtAsyncFor
See also AsyncFor
StmtAsyncFunctionDef
See also AsyncFunctionDef
StmtAsyncWith
See also AsyncWith
StmtAugAssign
See also AugAssign
StmtBreak
See also Break
StmtClassDef
See also ClassDef
StmtContinue
See also Continue
StmtDelete
See also Delete
StmtExpr
See also Expr
StmtFor
See also For
StmtFunctionDef
See also FunctionDef
StmtGlobal
See also Global
StmtIf
See also If
StmtImport
See also Import
StmtImportFrom
See also ImportFrom
StmtMatch
See also Match
StmtNonlocal
See also Nonlocal
StmtPass
See also Pass
StmtRaise
See also Raise
StmtReturn
See also Return
StmtTry
See also Try
StmtTryStar
See also TryStar
StmtTypeAlias
See also TypeAlias
StmtWhile
See also While
StmtWith
See also With
TextSize
A measure of text length. Also, equivalently, an index into text.
TypeIgnoreTypeIgnore
See also TypeIgnore
TypeParamParamSpec
See also ParamSpec
TypeParamTypeVar
See also TypeVar
TypeParamTypeVarTuple
See also TypeVarTuple
UnaryOpInvert
UnaryOpNot
UnaryOpUAdd
UnaryOpUSub
WithItem
See also withitem

Enums§

Ast
BoolOp
See also boolop
CmpOp
See also cmpop
Constant
ConversionFlag
Transforms a value prior to formatting it.
ExceptHandler
See also excepthandler
Expr
See also expr
ExprContext
See also expr_context
Mod
See also mod
Operator
See also operator
Pattern
See also pattern
Stmt
See also stmt
TypeIgnore
See also type_ignore
TypeParam
See also type_param
UnaryOp
See also unaryop

Traits§

Node
Ranged

Type Aliases§

OptionalRange
String
Suite